package com.yc.http.v1.impl;

import com.yc.http.v1.*;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/myinfo.s")
public class getLoginedUserServlet extends HttpServletImpl {

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        response.setContentType("text/html;charset=utf-8");
        final PrintWriter out = response.getWriter();
        final HttpSession session = request.getSession();
        final Object name = session.getAttribute("myinfo");
        if(name == null){
            out.append("请先登录!")
                    .append("<a href='login.html'>去登录</a>");
        } else {
            out.append("欢迎:").append(name.toString());
        }
    }
}
